package com.chaos.auth.controller;

import com.chaos.auth.api.dto.auth.RbacMenuChildrenDto;
import com.chaos.auth.service.RbacMenuService;
import com.chaos.auth.service.RbacRoleMenuBtnService;
import com.chaos.auth.service.RbacUserRoleService;
import com.chaos.framework.model.dto.result.list.ListResult;
import com.chaos.framework.starter.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Jacky.Cui
 * @since 2024-11-13
 */
@Slf4j
@RestController
@Api(tags = "")
@RequestMapping("/rbacMenu")
public class RbacMenuChildrenController extends BaseController<RbacMenuChildrenDto> {
    @Resource
    private RbacMenuService rbacMenuService;


    @PostMapping("/recursiveMenus/list.admin")
    @ApiOperation(value = "获取递归菜单", httpMethod = "POST")
    public ListResult<RbacMenuChildrenDto> recursiveMenus() {
        RbacMenuChildrenDto query = new RbacMenuChildrenDto();
        List<RbacMenuChildrenDto> allMenus = rbacMenuService.selectByData(query);
        List<RbacMenuChildrenDto> recursiveMenus = rbacMenuService.buildMenuTree(allMenus);
        return listResult(recursiveMenus);
    }


}
